package com.onpositive.datamap.core.impl;

import java.util.BitSet;

import com.onpositive.data.FilterTester;
import com.onpositive.data.IPropertyMetadata;
import com.onpositive.data.diskstorage.AbstractObjectCollection;
import com.onpositive.data.diskstorage.AbstractValueAccessor;
import com.onpositive.datamap.core.IDataProperty;

public abstract class DataProperty extends AbstractDataProperty implements IDataProperty {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public DataProperty(IPropertyMetadata meta,
			AbstractValueAccessor collection) {
		super(meta,collection);		
	}
	
	public Object aggregate(String aggregator, BitSet rs) {
		FilterTester filterTester = ((AbstractObjectCollection) accessor)
				.getFilterTester(getId(), null,
						null);
		int op=-1;
		if (aggregator.equals(MIN)){
			op=FilterTester.AGR_MIN;
		}
		if (aggregator.equals(MAX)){
			op=FilterTester.AGR_MAX;
		}
		if (aggregator.equals(SUM)){
			op=FilterTester.AGR_SUM;
		}
		if (aggregator.equals(AVE)){
			op=FilterTester.AGR_AVE;
		}
		if (aggregator.equals(IDENT)){
			op=FilterTester.AGR_IDE;
		}
		return filterTester.aggregate(op, rs);
	}

	public abstract IDataProperty clone(AbstractValueAccessor va);
}
